﻿namespace Sai.Test.TestDataBuilders
{
	using System;
	using System.Text;

	public class MamlTextFileBuilder : IBuildable
	{
		private string guid = Guid.NewGuid().ToString();
		private string title = "Fake Title";
		private string content = "Fake Content";

		public static MamlTextFileBuilder MamlFile()
		{
			return new MamlTextFileBuilder();
		}

		public MamlTextFileBuilder WithGuid(string guid)
		{
			this.guid = guid;

			return this;
		}

		public string Build()
		{
			var builder = new StringBuilder();

			builder.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
			builder.AppendFormat("\t<topic id=\"{0}\" revisionNumber=\"1\">", this.guid);
			builder.AppendLine();
			builder.AppendLine("\t\t<developerConceptualDocument xmlns=\"http://ddue.schemas.microsoft.com/authoring/2003/5\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">");
			builder.AppendLine("    <introduction>");
			builder.AppendFormat("      <para>{0}</para>", this.title);
			builder.AppendLine();
			builder.AppendLine("    </introduction>");
			builder.AppendLine("    <section>");
			builder.AppendFormat("      <title>{0}</title>", this.title);
			builder.AppendLine();
			builder.AppendLine("      <content>");
			builder.AppendFormat("      <para>{0}</para>", this.content);
			builder.AppendLine();
			builder.AppendLine("      </content>");
			builder.AppendLine("    </section>");
			builder.AppendLine("  </developerConceptualDocument>");
			builder.AppendLine("</topic>");

			return builder.ToString();
		}
	}
}
